package com.ms.util;


import org.apache.log4j.PropertyConfigurator;

import java.util.Properties;

/**
 * Created by RAZANERO on 11/04/14.
 */
public class LogUtil {
    public static void initInter(String rootCategory,String fileName) {
        Properties log4j = new Properties();
        log4j.put("log4j.rootLogger", rootCategory + ",LOGFILE");
        String category = rootCategory.equals("INFO") ? "FATAL" : "DEBUG";
        log4j.put("log4j.logger.com.dpwc", rootCategory);
        log4j.put("log4j.appender.LOGFILE", "org.apache.log4j.DailyRollingFileAppender");
        log4j.put("log4j.appender.LOGFILE.file", "/d01/app/app-tomcat/logs/"+fileName+".log");
        log4j.put("log4j.appender.LOGFILE.MaxBackupIndex", "10");
        log4j.put("log4j.appender.LOGFILE.append", "true");
        log4j.put("log4j.appender.LOGFILE.DatePattern", "'.'yyyy-MM-dd");
        log4j.put("log4j.appender.LOGFILE.layout", "org.apache.log4j.PatternLayout");
        log4j.put("log4j.appender.LOGFILE.layout.ConversionPattern", "%d{yyyy/MM/dd HH:mm:ss,SSS} [%10t] %-5p %-20c{1} - %m%n");

        log4j.put("log4j.logger.java.sql", category);
        log4j.put("log4j.logger.org.springframework.jdbc", category);
        log4j.put("log4j.logger.java.sql.PreparedStatement", category);
        log4j.put("log4j.logger.org.hibernate.transaction", category);
        log4j.put("log4j.logger.org.hibernate.SQL", category);
        log4j.put("log4j.logger.org.springframework.jdbc.core", category);
        log4j.put("log4j.logger.org.springframework.orm.hibernate", category);
        log4j.put("log4j.logger.org.springframework.jdbc.datasource", category);
        PropertyConfigurator.configure(log4j);
    }
}

